<?php
ini_set('memory_limit', '200M');
require_once __dir__.'/../common.php';

//$image = imagecreatefromjpeg('bjmap.jpg');
//$image = imagecreatefrompng('worldmap.png');
$image = imagecreatefromgif('worldmap.gif');

$image_p = imagecreatetruecolor(BRICK_SIZE, BRICK_SIZE);

$scale = 10;

for ($bx=0; $bx<ceil(imagesx($image)*$scale/BRICK_SIZE); $bx++)
{
	echo $bx."/".ceil(imagesx($image)*$scale/BRICK_SIZE)."\n";
	for ($by=0; $by<ceil(imagesy($image)*$scale/BRICK_SIZE); $by++)
	{
		imagecopyresized($image_p, $image, 0, 0, $bx*BRICK_SIZE/$scale, $by*BRICK_SIZE/$scale,
			BRICK_SIZE, BRICK_SIZE, BRICK_SIZE/$scale, BRICK_SIZE/$scale);
	
		imagejpeg($image_p, "bricks/brick_".$bx."_".$by.".jpg", 80);
	}
}
